package com.tianshi.pxx.conf;

import com.tianshi.pxx.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {
    public void addInterceptors(InterceptorRegistry registry) {
        //添加强制登录拦截器
        //排除不需要登录的路径
        //怎么排除首页？
        //registry.addInterceptor(new LoginInterceptor()).addPathPatterns("/**")
        //        .excludePathPatterns("/login")
        //        .excludePathPatterns("/register")
        //        .excludePathPatterns("/index.html");

        registry.addInterceptor(new LoginInterceptor()).addPathPatterns("/pages/product.html")
                .addPathPatterns("/pages/cart.html")
                .addPathPatterns("/pages/mine.html");


    }
}
